package com.huashizhaoxi.lionapp.dao;

import com.fasterxml.jackson.databind.annotation.JsonValueInstantiator;
import com.huashizhaoxi.lionapp.entity.Payment;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface PayMapper {
    @Insert("insert into payment (order_id, nonce_str, prepay_id, pay_sign, timestamp, status) values (#{order_id}, #{nonce_str}, #{prepay_id}, #{pay_sign}, #{timestamp}, #{status})")
    void addPayment(Payment payment);

    @Select("select status from payment where order_id = #{orderNo}")
    int checkOrder(String orderNo);

    @Select("update payment set transaction_id = #{transactionId} where order_id = #{orderNo}")
    void updateOrder(String orderNo, String transactionId);

    @Update("update payment set status = #{state} where order_id = #{orderNo}")
    void changeStatus(String orderNo, int state);

    @Select("select * from payment where order_id = #{orderNo}")
    Payment getPayConfig(String orderNo);
}
